/*
    This file is part of Darwin.

    Darwin is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    Foobar is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Foobar; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    
    Darwin uses GALib
    Copyright (c) 1995-1996 Massachusetts Institute of Technology (MIT)
    Copyright (c) 1996-2005 Matthew Wall
    All rights reserved.
    
    Darwin uses ConfigFile
    Copyright (c) 2004 Richard J. Wagner
     
    Darwin, a Genetic Algorithm to solve Timetabling problem
    Copyright (c) 2006 Christian S. Perone
*/  

#if !defined(__TIMEGENOME_H)
#define __TIMEGENOME_H

#include "general.h"

#include "dbanalysis.h"
#include "options.h"

#include "tablemapping.h"
#include "structmapping.h"

extern mysqlpp::Connection g_connection;
extern GlobalOptions g_options;

extern MapProfessorDisciplina map_professordisciplina;
extern MapDisciplina map_disciplina;
extern MapOferecimento map_oferecimento;
extern MapCurso map_curso;
extern MapProfessor map_professor;
extern MapDisponibilidade map_disponibilidade;
extern MapDiaSemana map_diasemana;

class TimeGenome : public GAGenome
{
public:
     GADefineIdentity("TimeGenome", 666);
     
     static void Init(GAGenome &);
     static int Mutate(GAGenome &, float);
     static float Compare(const GAGenome &, const GAGenome &);
     static float Evaluate(GAGenome &);

     // Crossovers 
     // 1) Crossover 2-point para cada turno de cada nível
     static int CrossOnePointTurno(const GAGenome &, const GAGenome &, GAGenome *, GAGenome *);
     static int CrossOnePointNivel(const GAGenome &, const GAGenome &, GAGenome *, GAGenome *);

public:
     static void Shake_Genome(GAGenome &);
     static void AddDisciplina(std::vector<int> &, int, int, int);
     
public:

     TimeGenome(int niveis);
     TimeGenome(const TimeGenome &orig);
     virtual ~TimeGenome();

     TimeGenome& operator=(const GAGenome &orig)
     {
          if(&orig != this) copy(orig);
          return *this;
     }
     
     virtual GAGenome* clone(CloneMethod) const		{ return new TimeGenome(*this); }
     virtual void copy(const GAGenome &orig);
 
public:
     int GetNiveis(void) const 				{ return mNiveis; }
     std::vector<int> & GetNivelList(int i)	{ return *mListNiveis[i]; } 

protected:
     int			mNiveis;
     std::vector<int>		**mListNiveis;
     
     
};

#endif
